package com.wuliu.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wuliu.common.utils.DateUtils;

import javax.annotation.Resource;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.wuliu.system.mapper.BasAdvSetMapper;
import com.wuliu.system.domain.BasAdvSet;
import com.wuliu.system.service.IBasAdvSetService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 广告设置Service业务层处理
 *
 * @author realue
 * @date 2023-11-09
 */
@Service
@RequiredArgsConstructor
public class BasAdvSetServiceImpl extends ServiceImpl<BasAdvSetMapper, BasAdvSet> implements IBasAdvSetService {
    private final BasAdvSetMapper basAdvSetMapper;

    /**
     * 查询广告设置
     *
     * @param id 广告设置主键
     * @return 广告设置
     */
    @Override
    public BasAdvSet selectBasAdvSetById(String id) {
        return basAdvSetMapper.selectBasAdvSetById(id);
    }

    /**
     * 查询广告设置列表
     *
     * @param basAdvSet 广告设置
     * @return 广告设置
     */
    @Override
    public List<BasAdvSet> selectBasAdvSetList(BasAdvSet basAdvSet) {
        return basAdvSetMapper.selectBasAdvSetList(basAdvSet);
    }

    /**
     * 新增广告设置
     *
     * @param basAdvSet 广告设置
     * @return 结果
     */
    @Override
    public int insertBasAdvSet(BasAdvSet basAdvSet) {
        basAdvSet.setCreateTime(DateUtils.getNowDate());
        return basAdvSetMapper.insertBasAdvSet(basAdvSet);
    }

    /**
     * 修改广告设置
     *
     * @param basAdvSet 广告设置
     * @return 结果
     */
    @Override
    public int updateBasAdvSet(BasAdvSet basAdvSet) {
        basAdvSet.setUpdateTime(DateUtils.getNowDate());
        return basAdvSetMapper.updateBasAdvSet(basAdvSet);
    }

    /**
     * 批量删除广告设置
     *
     * @param ids 需要删除的广告设置主键
     * @return 结果
     */
    @Override
    public int deleteBasAdvSetByIds(String[] ids) {
        return basAdvSetMapper.deleteBasAdvSetByIds(ids);
    }

    /**
     * 删除广告设置信息
     *
     * @param id 广告设置主键
     * @return 结果
     */
    @Override
    public int deleteBasAdvSetById(String id) {
        return basAdvSetMapper.deleteBasAdvSetById(id);
    }

    /**
     * 查询广告
     *
     * @param type
     * @param position
     * @param sysAccount
     * @return
     */
    @Override
    public List<BasAdvSet> getList(Integer type, Integer position, String sysAccount) {
        return basAdvSetMapper.selectList(new LambdaQueryWrapper<BasAdvSet>()
                .eq(BasAdvSet::getSysAccount, sysAccount)
                .eq(BasAdvSet::getEnabled, 1)
                .eq(BasAdvSet::getPosition, position)
                .orderByAsc(BasAdvSet::getOrderNo));
    }
}
